/**
 * cmd
 */
/*window.ip = "http://120.77.83.63:8180/baod/";//开发测试*/
window.ip = "http://120.76.42.60:8080/baod/";//测试人员测试

window.urls ={
	login:ip+"login.shtml",//登录
    exit:ip+"exist.shtml",//退出系统
    deviceMap:ip+"map/map.shtml",//首页设备地图
	deviceMapPermit:ip+"device/permit.shtml",//首页设备地图权限
    monitorScreen:ip+"device/dataMonitoring.shtml",//首页监控大屏
    msgLogin:ip+"verificationCodeLogin.shtml",//手机号登录
    getMsgCode:ip+"getVerificationCode.shtml",//获取登录验证码
	  topMenu:ip+"index.shtml",//头部导航
	  regNewAccout:ip+"user/addEntity.shtml",//新增账号
    editaAccout:ip+"user/editEntity.shtml",//编辑账号
	userInfo:ip+"user/info.shtml",//账号信息
	updateAccountName:ip+"user/updateAccountName.shtml",//更新手机号
	  getAccoutlists:ip+"user/findByPage.shtml",//获取用户列表
	  disabledAccout:ip+"user/updateState.shtml",//账号启用禁用设置
    eventLists:ip+"deviceEvent/findByPage.shtml",//获取事件列表
    eventTypes:ip+"deviceEvent/types.shtml",//获取事件类别
    eventTypesName:ip+"deviceEvent/categorys.shtml",//获取事件类型
    deleteEvents:ip+"deviceEvent/delete.shtml",//删除事件
    handleEvents:ip+"deviceEvent/deal.shtml",//处理事件
    getFastView:ip+"deviceEvent/exportExcel.shtml",//导出事件
    checkMachinelist:ip+"device/findByPage.shtml",//查询设备列表
    getMachineBtns:ip+"device/operate.shtml",//设备列表页获取按钮(公共三级菜单按钮)
    checkHandellog:ip+"log/findByPage.shtml",//查询操作日志
    getPermissions:ip+"resources/permissions.shtml",//分配权限列表
    changePermissions:ip+"resources/addUserRes.shtml",//修改分配权限
    checkPermissions:ip+"resources/findAuthByRole.shtml",//根据角色查询权限
    getDeviceYfp:ip+"user/device/distributed.shtml",//获取用户已分配设备
    getDeviceWFP:ip+"user/device/undistributed.shtml",//获取用户未分配设备
    onORoffmsg:ip+"user/message/switch.shtml",//短信通知开关
    bindingDevices:ip+"user/device/bind.shtml",//分配设备
    unbindDevices:ip+"user/device/unbind.shtml",//设备解绑
    deljhLogs:ip+"commandLog/deleteEntity.shtml",//删除交互记录
    smslogLists:ip+"smslog/findByPage.shtml",//短信记录
    checkjhLogs:ip+"commandLog/findByPage.shtml",//查询交互记录
    getlogmodules:ip+"log/module.shtml",//获取操作日志模块
    getlogMethods:ip+"log/methods.shtml",//获取操作日志模块方法
    getDeviceCTRlists:ip+"deviceType/findByPage.shtml",//获取控制器类型列表
    newAddDeviCtrType:ip+"deviceType/addEntity.shtml",//新增控制器类型
    editDeviCtrType:ip+"deviceType/editEntity.shtml",//编辑控制器类型
    checkallDeviceTypeParam:ip+"deviceType/allDeviceTypeParam.shtml",//查询对应控制器所有参数
    saveDeviceTypeParam:ip+"deviceType/saveDeviceTypeParam.shtml",//修改控制类类型参数
    addNewDevices:ip+"device/addEntity.shtml",//设备添加
    editDevices:ip+"device/editEntity.shtml",//设备编辑修改
    delsDevices:ip+"device/deleteEntity.shtml",//删除设备
    shareDevices:ip+"device/share.shtml",//设备分享
    fastViewDevices:ip+"deviceEvent/fastView.shtml",//设备列表（快捷视图查询）
    getNewestDevicedetils:ip+"setting/1/calc.shtml",//设备详情-最新记录列表
    getPastDevicedetils:ip+"setting/2/calc.shtml",//设备详情-历史纪录列表
    operateDevicesAllTimeWatch:ip+"setting/operate.shtml",//设备详情-操作设备(实时监控)
    getDeviceInfo:ip+"device/info.shtml",//设备详情-地图右侧信息
    setDeviceslocation:ip+"device/location.shtml",//设备详情-修改设备定位
    deviceEventClassify:ip+"deviceEvent/classify.shtml",//设备详情-获取事件视图(获取设备的事件分类和数量)
    getKeynames:ip+"setting/getnames.shtml",//设备详情-根据key获取属性
    saveParams:ip+"setting/saveParams.shtml",//更多参数-保养参数--保存参数
    getParams_refresh:ip+"setting/getParams.shtml",//更多参数--刷新参数
    getParams_returnValue:ip+"setting/getStatus.shtml",//更多参数--刷新参数-获取设备返回参数
    getDeviceRunParams:ip+"setting/1/params.shtml",//设备详情-运行参数
    moreParams_Baoyang:ip+"setting/2/params.shtml",//更多参数-保养参数
    moreParams_users:ip+"setting/3/params.shtml",//更多参数-用户参数
    moreParams_factory:ip+"setting/4/params.shtml",//更多参数-厂家参数
    moreParams_network:ip+"setting/5/params.shtml",//更多参数-网络参数
    moreParams_debugger:ip+"setting/6/params.shtml",//更多参数-调试参数
    moreParams_senior:ip+"setting/7/params.shtml",//更多参数-高级参数
    moreParams_frequency:ip+"setting/8/params.shtml",//更多参数-变频器参数
    moreParams_frequencyReadWrite:ip+"setting/bpqRAW.shtml",//更多参数-变频器读写操作
    moreParams_frequencyReadWriteReturnData:ip+"setting/getConverterRw.shtml",//更多参数-变频器读写参数返回

}

window.detectToken = function() {
   var token = localStorage.getItem("token");
    if (token === null || token === undefined) {
            console.log("no token");
            var pA = window.location.href.split('/')[3];
            location.replace("login.html?url="+pA);
            window.location.href = "login.html?url="+pA;
    }
    return token;
};

//============layer Control menu START============
//tips：Use The Function Before The DOM Elements

var getOnelayerMenu = function(){
    $.ajax({ 
        type:"post", 
        url:urls.topMenu, 
        data: {token:localStorage.getItem("token")}, 
        dataType: 'json', 
        async : true,
        success:function(result){ 
            if(result.code == "1"){
                var topMenuHtml = '';
                for(var i=0;i<result.data.length;i++){
                    var topMenuHtml2 = '';
                    topMenuHtml += '<li  class="rela"><a class="cmHNb-a">'+result.data[i].name+'</a><div class="subtoggleMenu abso">';
                    if(result.data[i].children.length!=0){
                       for(var k=0;k<result.data[i].children.length;k++){
                            var forInVal = result.data[i].children[k].id;

                            switch (forInVal)
                            {
                            case 102:
                              topMenuHtml2 += '<a data-id="'+result.data[i].children[k].id+'" href="monitorScreen.html">'+result.data[i].children[k].name+'</a>';
                              break;
                            case 103:
                              topMenuHtml2 += '<a data-id="'+result.data[i].children[k].id+'" href="deviceMap.html">'+result.data[i].children[k].name+'</a>';
                              break;
                            case 202:
                              topMenuHtml2 += '<a data-id="'+result.data[i].children[k].id+'" href="machineList.html">'+result.data[i].children[k].name+'</a>';
                              break;
                            case 203:
                              topMenuHtml2 += '<a data-id="'+result.data[i].children[k].id+'" href="#">'+result.data[i].children[k].name+'</a>';
                              break;
                            case 302:
                              topMenuHtml2 += '<a data-id="'+result.data[i].children[k].id+'" href="eventslist.html">'+result.data[i].children[k].name+'</a>';
                              break;
                            case 303:
                              topMenuHtml2 += '<a data-id="'+result.data[i].children[k].id+'" href="#">'+result.data[i].children[k].name+'</a>';
                              break;
                            case 402:
                              topMenuHtml2 += '<a data-id="'+result.data[i].children[k].id+'" href="accoutManage.html">'+result.data[i].children[k].name+'</a>';
                              break;
                            case 403:
                              topMenuHtml2 += '<a data-id="'+result.data[i].children[k].id+'" href="#">'+result.data[i].children[k].name+'</a>';
                              break;
                            case 602:
                              topMenuHtml2 += '<a data-id="'+result.data[i].children[k].id+'" href="sysManage-baseInformation.html">'+result.data[i].children[k].name+'</a>';
                              break;
                            case 603:
                              topMenuHtml2 += '<a data-id="'+result.data[i].children[k].id+'" href="sysManage-equipmentMaintain.html">'+result.data[i].children[k].name+'</a>';
                              break;
                            case 604:
                              topMenuHtml2 += '<a data-id="'+result.data[i].children[k].id+'" href="sysManage-msgLog.html">'+result.data[i].children[k].name+'</a>';
                              break;
                            case 605:
                              topMenuHtml2 += '<a data-id="'+result.data[i].children[k].id+'" href="sysManage-handelLog.html">'+result.data[i].children[k].name+'</a>';
                              break;
                            case 606:
                              topMenuHtml2 += '<a data-id="'+result.data[i].children[k].id+'" href="sysManage-jiaohuLog.html">'+result.data[i].children[k].name+'</a>';
                              break;
                            }

                            
                        }
                    }
                    topMenuHtml += topMenuHtml2;
                    topMenuHtml += '</div></li>';
                    
                }
                $(".commonHeaderNavBox").html(topMenuHtml);
                $(".cmHNb-a").on("click",function(){
                    $(this).parent("li").siblings().find(".subtoggleMenu").hide("fast");
                    $(this).siblings(".subtoggleMenu").slideToggle();
                });
            }else{
              if(result.code==3000004){
                setTimeout('location.replace("login.html")',1500);
              }
            }
  
        } 
    });    
}


var getTwolayerMenu = function(levelCode,curId){
    $.ajax({ 
        type:"post", 
        url:urls.topMenu, 
        data: {token:localStorage.getItem("token")}, 
        dataType: 'json', 
        async : false,
        success:function(result){
          if(result.code==1){
            var mianshowbptrHtml = '';
            for(var i=0;i<result.data.length;i++){
                if(result.data[i].id==levelCode){
                    for(var j=0;j<result.data[i].children.length;j++){
						if(result.data[i].children[j].id==curId){
							mianshowbptrHtml +='<a class="cur" href="'+result.data[i].children[j].resKey+'" data-id="'+result.data[i].children[j].id+'">'+result.data[i].children[j].name+'</a>';	
						}else{
							mianshowbptrHtml +='<a href="'+result.data[i].children[j].resKey+'" data-id="'+result.data[i].children[j].id+'">'+result.data[i].children[j].name+'</a>';							
						}
                    }
                }
            }
            $(".mianshowbpt-r").html(mianshowbptrHtml);
          }else{
            $.flytip(result.msg);
          } 
        } 
    });    
}

var getThreelayerMenu = function(IDCode,dtuID){
    $.ajax({ 
        type:"post", 
        url:urls.getMachineBtns, 
        data: {token:localStorage.getItem("token"),id:IDCode}, 
        dataType: 'json', 
        async : false, 
        success:function(result){
          if(result.code==1){
            var tableTopbarlHtml = '';
            for(var i=0;i<result.data.length;i++){
                var forinVals2 = result.data[i].id;
                switch (forinVals2)
                {
                case 215://设备详情---更多参数---运行参数
                    tableTopbarlHtml +='<a data-id="'+result.data[i].id+'" href="morePara-maintainCoefficient.html?dtuid='+dtuID+'"><li>'+result.data[i].name+'</li></a>';
                  break;
                case 217://设备详情---更多参数---用户参数
                    tableTopbarlHtml +='<a data-id="'+result.data[i].id+'" href="morePara-userCoefficient.html?dtuid='+dtuID+'"><li>'+result.data[i].name+'</li></a>';
                  break;
                case 219://设备详情---更多参数---厂家参数
                    tableTopbarlHtml +='<a data-id="'+result.data[i].id+'" href="morePara-factoryCoefficient.html?dtuid='+dtuID+'"><li>'+result.data[i].name+'</li></a>';
                  break;
                case 221://设备详情---更多参数---网络参数
                    tableTopbarlHtml +='<a data-id="'+result.data[i].id+'" href="morePara-networkCoefficient.html?dtuid='+dtuID+'"><li>'+result.data[i].name+'</li></a>';
                  break;
                case 223://设备详情---更多参数---调试参数
                    tableTopbarlHtml +='<a data-id="'+result.data[i].id+'" href="morePara-debuggCoefficient.html?dtuid='+dtuID+'"><li>'+result.data[i].name+'</li></a>';
                  break;
                case 225://设备详情---更多参数---变频器参数
                    tableTopbarlHtml +='<a data-id="'+result.data[i].id+'" href="morePara-frequencyCoefficient.html?dtuid='+dtuID+'"><li>'+result.data[i].name+'</li></a>';
                  break;
                case 227://设备详情---更多参数---高级参数
                    tableTopbarlHtml +='<a data-id="'+result.data[i].id+'" href="morePara-seniorCoefficient.html?dtuid='+dtuID+'"><li>'+result.data[i].name+'</li></a>';
                  break;
                case 205:
                  if(result.data[i].ishide==1){
                    tableTopbarlHtml +='<a data-id="'+result.data[i].id+'" id="eventsDel" herf="javascript:;"><i class="xwl i-del pdr5"></i>'+result.data[i].name+'</a>';
                  }
                  break;
                case 206:
                  if(result.data[i].ishide==1){
                    tableTopbarlHtml +='<a data-id="'+result.data[i].id+'" id="eventsDel" herf="javascript:;"><i class="xwl i-del pdr5"></i>'+result.data[i].name+'</a>';
                  }
                  break;
                case 207:
                  if(result.data[i].ishide==1){
                    tableTopbarlHtml +='<a data-id="'+result.data[i].id+'" id="eventsDel" herf="javascript:;"><i class="xwl i-del pdr5"></i>'+result.data[i].name+'</a>';
                  }
                  break;
                case 208:
                  if(result.data[i].ishide==1){
                    tableTopbarlHtml +='<a data-id="'+result.data[i].id+'" id="eventsDel" herf="javascript:;"><i class="xwl i-del pdr5"></i>'+result.data[i].name+'</a>';
                  }
                  break;
                case 229://设备详情--交互记录--删除
                    tableTopbarlHtml +='<a data-id="'+result.data[i].id+'" id="eventsDel" herf="javascript:;"><i class="xwl i-del pdr5"></i>'+result.data[i].name+'</a>';
                  break;
                case 613://设备详情--短信记录--删除
                  tableTopbarlHtml +='<a data-id="'+result.data[i].id+'" id="eventsDel" herf="javascript:;"><i class="xwl i-del pdr5"></i>'+result.data[i].btn+'</a>';
                  break;
                case 614:
                  tableTopbarlHtml +='<a data-id="'+result.data[i].id+'" id="eventsDel" herf="javascript:;"><i class="xwl i-del pdr5"></i>'+result.data[i].btn+'</a>';
                  break;
                case 612:
                  tableTopbarlHtml +='<a data-id="'+result.data[i].id+'" id="eventsDel" herf="javascript:;"><i class="xwl i-del pdr5"></i>'+result.data[i].btn+'</a>';
                  break;
                case 607:
                  $(".baseInfoEditBtns").html('<span class="newAddDeviCtr" data-id="'+result.data[i].id+'"><i class="xwl i-add pdr5"></i>新增</span>');
                  break;
                case 608:
                  $(".baseInfoNewAddBtns").html('<span class="newEditDeviCtr" data-id="'+result.data[i].id+'"><i class="xwl i-edit pdr5"></i>编辑</span>');
                  break;
                case 609:
                  $(".baseInfoBox-rSavebtn").html('<a class="baseInfoSaveBtn" data-id="'+result.data[i].id+'">保存</a>');
                  break;
                case 404:
                  tableTopbarlHtml +='<a data-id="'+result.data[i].id+'" class="addNewing" data-code="2" herf="javascript:;"><i class="xwl i-add pdr5"></i>'+result.data[i].btn+'</a>';
                  break;
                case 405:
                  tableTopbarlHtml +='<a data-id="'+result.data[i].id+'" class="editing" data-code="3" herf="javascript:;"><i class="xwl i-edit pdr5"></i>'+result.data[i].btn+'</a>';
                  break;
                case 406:
                  tableTopbarlHtml +='<a data-id="'+result.data[i].id+'" class="fpJurisd" data-code="4" herf="javascript:;"><i class="xwl i-user pdr5"></i>'+result.data[i].btn+'</a>';
                  break;
                case 407:
                  tableTopbarlHtml +='<a data-id="'+result.data[i].id+'" class="fpBtns" data-code="5" herf="javascript:;"><i class="xwl i-fp pdr5"></i>'+result.data[i].btn+'</a>';
                  break;
                case 308:
                  tableTopbarlHtml +='<a id="eventsHandel" herf="javascript:;"><i class="xwl i-cl pdr5"></i>'+result.data[i].btn+'</a>';
                  break;
                case 309:
                  tableTopbarlHtml +='<a id="eventsDel" herf="javascript:;"><i class="xwl i-del pdr5"></i>'+result.data[i].btn+'</a>';
                  break;
                case 310:
                  tableTopbarlHtml +='<a id="daochuImg" herf="javascript:;"><i class="xwl i-dc pdr5"></i>'+result.data[i].btn+'</a>';
                  break;
                case 209://设备列表-->设备新增
                  tableTopbarlHtml +='<a data-id="'+result.data[i].id+'"  class="newMachineAdds" herf="javascript:;"><i class="xwl i-add pdr5"></i>'+result.data[i].btn+'</a>';
                  break;
                case 210://设备列表-->设备编辑
                  tableTopbarlHtml +='<a data-id="'+result.data[i].id+'"  class="machineEdits" herf="javascript:;"><i class="xwl i-edit pdr5"></i>'+result.data[i].btn+'</a>';
                  break;
                case 211://设备列表-->设备删除
                  tableTopbarlHtml +='<a data-id="'+result.data[i].id+'"  class="machineDels" herf="javascript:;"><i class="xwl i-del pdr5"></i>'+result.data[i].btn+'</a>';
                  break;
                case 212://设备列表-->设备分享
                  tableTopbarlHtml +='<a data-id="'+result.data[i].id+'"  class="machineShares" herf="javascript:;"><i class="xwl i-share pdr5"></i>'+result.data[i].btn+'</a>';
                  break;
                } 

            }
            $(".tableTopbar-l").html(tableTopbarlHtml);
          }/*else{
            $.flytip(result.msg);
          }*/

        } 
    });    
}

//============layer Control menu END ============

//============loginUser editFile START============
function showPopup(){ 
    var oDivs = document.createElement('div');
    oDivs.id = 'loginUserEditLayer';
    oDivs.className = 'layerBoxing';
    document.body.appendChild(oDivs);
    var sbar = document.getElementById("loginUserEditLayer");
    var masking = document.getElementById("closeMasking");
        sbar.innerHTML = "<div class='clearfix layerboxTitle mgc'><span class='layerboxTitleName fl'>修改个人资料</span><a onclick='hidePopup();' class='closeLayerbox txtc fr'><i class='xwl i-closeBtn'></i></a></div>"+
        "<form class='mainFormbox mgc' action='' method='' accept-charset='utf-8'>"+
            "<div class='formeachlaber'><i>*账号：</i><input id='loginUserActName' class='yurname2 formenterEach' placeholder='请输入账号/手机号' readonly='true'></div>"+
            "<div class='formeachlaber'><i>*密码：</i><input id='loginUserPswCode' type='password' class='yurpsw2 formenterEach' placeholder='请输入密码'></div>"+
            "<div class='formeachlaber'><i>*昵称：</i><input id='loginUserNickName' class='yurnkn2 formenterEach' placeholder='请输入昵称'></div>"+
            "<div class='formeachlaber rela'><i>创建者：</i><input id='loginUserCreated' class='formenterEach' value='' placeholder='' readonly='true'>"+
                //"<select class='yurauthr3 abso'>"+
                //"</select>"+
            "</div>"+
            "<div class='layeringQYbox formeachlaber rela nosee'>"+
                "<i>创建日期：</i><input class='formenterEach createdDate' value='' placeholder='创建日期'>是否启用："+
                "<div data-flag='0' class='zanshinosee2 layerqiyong toggleSwitch toggleLayerSwitchBtns toggleSwitchIDing'><input type='checkbox'><span class='btn'></span><span class='bg'></span></div>"+
            "</div>"+
            "<div class='formSubmitBtn mgc clearfix'><a onclick='editLoginUserFile_Save();' id='loginUserSureBtn'>确定</a><a onclick='hidePopup();' class='cancelBtning'>取消</a></div>"+
        "</form>";
    masking.style.display = "block";
    sbar.style.display = "block";
} 
function hidePopup(){ 
    var popUp = document.getElementById("loginUserEditLayer");
    var maskHide = document.getElementById("closeMasking");
    popUp.style.display = "none";
    maskHide.style.display = "none";
}
var maskDivs = document.createElement('div');
    maskDivs.id = 'closeMasking';
    maskDivs.className = 'masking';
    document.body.appendChild(maskDivs);

if(document.getElementById("loginUserNameText")!=undefined){
  document.getElementById("loginUserNameText").innerHTML = localStorage.getItem("userName");  
}
if(document.getElementById("yourActSetting")!=undefined){
    document.getElementById("yourActSetting").addEventListener("click",function(){
        showPopup();
        document.getElementById("loginUserActName").value =localStorage.getItem("dengluzhe_actName");
        document.getElementById("loginUserPswCode").value =localStorage.getItem("dengluzhe_psw");
        document.getElementById("loginUserNickName").value =localStorage.getItem("userName");
        $.post(urls.userInfo,{token:localStorage.getItem("token"),id:localStorage.getItem("dengluzhe_id")}, 
            function(result){
                if(result.code == "1"){
                    //var yurauthrHtml = '<option value ="'+localStorage.getItem("dengluzhe_id")+'">'+localStorage.getItem("userName")+'</option>';
                   // for(var i=0;i<result.data.records.length;i++){
                    //    yurauthrHtml +='<option value ="'+result.data.records[i].id+'">'+result.data.records[i].accountName+'</option>';
                    //}
                    //$(".yurauthr3").html(yurauthrHtml);
					$("#loginUserCreated").val(result.data.parentName);
                }else{
                    $.flytip(result.msg);
                }

            },"json");
    })
}
if(document.getElementById("exitSystem")!=undefined){
    document.getElementById("exitSystem").addEventListener("click",function(){
        var token = detectToken();
        $.ajax({ 
            type:"post", 
            url:urls.exit, 
            data: {token:token},
            dataType: 'json', 
            async : true,
            success:function(result){
                if(result.code==1){
                    $.flytip(result.msg);
                    localStorage.removeItem("token");
                    detectToken();
                }else{
                    $.flytip(result.msg);
                }
            } 
        });
    })
}
var editLoginUserFile_Save = function(){
    var token = detectToken();
    var userName = document.getElementById("loginUserNickName").value;
    var password = document.getElementById("loginUserPswCode").value;
    var id = localStorage.getItem("dengluzhe_id");
    $.vloading.show();
    $.ajax({ 
        type:"post", 
        url:urls.editaAccout, 
        data: {token:token,userName:userName,password:password,id:id}, 
        dataType: 'json', 
        async : true,
        success:function(result){
            $.vloading.remove();
            $("#loginUserBar").find("p").html(userName);
            userName = localStorage.setItem("userName", userName);
            dengluzhe_id = localStorage.setItem("dengluzhe_id", id);
            dengluzhe_psw = localStorage.setItem("dengluzhe_psw",password);
            $.flytip(result.msg);
            hidePopup();
        } 
    });
      
}

var maxTimes = 5;
var intervalTime = 1000;
var remainTimes = maxTimes;
var task;

var show = function()  //显示隐藏层和弹出层
{
   var hideobj=document.getElementById("hidebg");
   hidebg.style.display="block";  //显示隐藏层
}
var hide = function()  //去除隐藏层和弹出层
{
   document.getElementById("hidebg").style.display="none";
}


var saveReload = function()  //重新加载
{
   var maxTimes = 3;
   $.flytip("保存中 3");
   setInterval(function (){	
	   maxTimes--;
	   $.flytip("保存中 " + maxTimes)
   },1000)
   show();
   setTimeout('window.location.reload()', 3000);
}


var moreParams_refreshedReturnVal = function(dtuID){
  $("body").on("click",".moreParams_refreashedBtn",function(){
      var token = detectToken();
      var getyouWantParams = $(".validateInput");
      var getyouWantParams_Arr = [];
      var is_connected = $("#moreParamsForm").attr("data-connected");
      if(is_connected!=0){
          for(var i=0;i<getyouWantParams.length;i++){
              getyouWantParams_Arr.push(getyouWantParams.eq(i).attr("table_param"));
          }
          $.ajax({ 
              type:"post", 
              url:urls.getParams_refresh, 
              data: {token:token,dtu_id:dtuID,params:getyouWantParams_Arr.join(",")},
              dataType: 'json', 
              async : true, 
              success:function(result){
                  if(result.code=="1"){
					  show();
					  $.flytip("获取剩余时间" + remainTimes + "秒");
					  task = setInterval(function (){	
						remainTimes--;
						if(remainTimes > 0) {
							$.ajax({ 
							type:"post", 
							url:urls.getParams_returnValue, 
							data: {token:token,queryId:result.data.queryId},
							//data: {token:token,queryId:queryId}, 
							dataType: 'json', 
							async : true, 
							success:function(result){//need countdown time
							  if(result.code==1){
								  if (result.data.last_update != null && result.data.last_update != undefined && result.data.last_update != '')
								  {
									  remainTimes = maxTimes;
									  clearInterval(task);
									  $(".moreParams_upDatetime").html(result.data.last_update);
									  //Matches the parameters returned by the query to update the data
									  //for(var k in result.data){
										  //var idx = getyouWantParams_Arr.indexOf(k);
										  //if(idx != -1){
											  //Special processing judgment, the button is switch, according to 0/1 judge to open the closed state
											  //if(getyouWantParams.eq(idx).attr("type")=="checkbox"){
												//getyouWantParams.eq(idx).removeAttr("checked");
											  //}else{
												//getyouWantParams.eq(idx).val(result.data[k]).attr("update-val",result.data[k]).css("font-weight","bold");                                          
											//  }
										 // }
									   //}
									  hide();
									  $.flytip(result.msg);
									  setTimeout('window.location.reload()', 500);
								  }else{
									  $.flytip("获取剩余时间" + remainTimes + "秒");
								  }
							  }else{
								  hide();
								  $.flytip(result.msg);
							  }
							} 
							});
	}else{
		$.flytip('已超时');
		hide();
		remainTimes = maxTimes;
		clearInterval(task);
	}
}, intervalTime);
                  }else{
					  hide();
                      $.flytip(result.msg);
                      return false;
                  }
              } 
          });
      }else{
		  hide();
          $.flytip("当前设备不在线，无法操作");
      }

  })
}


//============loginUser editFile END============
function getParam(name,value,type){
    var loca = window.location;
    var baseUrl = type==undefined ? loca.origin + loca.pathname + "?" : "";
    var query = loca.search.substr(1);

    if (name==undefined) { return query }

    if (value==undefined){
        var val = query.match(new RegExp("(^|&)"+ name +"=([^&]*)(&|$)"));
        return val!=null ? unescape(val[2]) : null;
    };
    var url;
    if (query=="") {

        url = baseUrl + name + "=" + value;
    }else{

        var obj = {};
        var arr = query.split("&");
        for (var i = 0; i < arr.length; i++) {
            arr[i] = arr[i].split("=");
            obj[arr[i][0]] = arr[i][1];
        };
        obj[name] = value;
        url = baseUrl + JSON.stringify(obj).replace(/[\"\{\}]/g,"").replace(/\:/g,"=").replace(/\,/g,"&");
    };
    return url;
}

function disabledBtnStatus(){
    var ifkaiqiStatus = 0;
    $("body").on("click",".toggleSwitch",function(){
        event.stopPropagation();
        var curBtnStatusCode = $(this).attr("data-flag");
        if(ifkaiqiStatus==0){
            if(curBtnStatusCode==1){
                $(this).attr("data-flag","0").find("input").val(0);
            }else{
                $(this).attr("data-flag","1").find("input").val(1);
            }
            ifkaiqiStatus=1;
        }else{
            if(curBtnStatusCode==1){
                $(this).attr("data-flag","0").find("input").val(0);
            }else{
                $(this).attr("data-flag","1").find("input").val(1);
            }
            ifkaiqiStatus=0;
        }
    })      
}
var pageNav=pageNav||{};pageNav.fn=null;pageNav.nav=function(p,pn){if(pn<=1){this.p=1;this.pn=1;return this.pHtml2(1)}if(pn<p){p=pn};var re="";if(p<=1){p=1}else{re+=this.pHtml(p-1,pn,"<");re+=this.pHtml(1,pn,"1")}this.p=p;this.pn=pn;var start=2;var end=(pn<9)?pn:9;if(p>=7){re+="...";start=p-4;var e=p+4;end=(pn<e)?pn:e}for(var i=start;i<p;i++){re+=this.pHtml(i,pn)};re+=this.pHtml2(p);for(var i=p+1;i<=end;i++){re+=this.pHtml(i,pn)};if(end<pn){re+="...";re+=this.pHtml(pn,pn)};if(p<pn){re+=this.pHtml(p+1,pn,">")};return re};pageNav.pHtml=function(pageNo,pn,showPageNo){showPageNo=showPageNo||pageNo;var H=" <a href='javascript:pageNav.go("+pageNo+","+pn+");' class='pageNum'>"+showPageNo+"</a> ";return H};pageNav.pHtml2=function(pageNo){var H=" <span class='cPageNum'>"+pageNo+"</span> ";return H};pageNav.go=function(p,pn){document.getElementById("pageNav").innerHTML=this.nav(p,pn);if(this.fn!=null){this.fn(this.p,this.pn)}};
function stop(){return false;}document.oncontextmenu=stop;document.oncontextmenu = function () { return false; };document.onkeydown = function(){if(window.event && window.event.keyCode == 123) {event.keyCode=0;event.returnValue=false;}}